﻿using Mysoft.QuickCode.Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Mysoft.QuickCode.Xml
{
    /// <summary>
    /// Xml转换工具
    /// </summary>
    public class XmlConvert
    {
        /// <summary>
        /// 对象序列化为xml
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string SerializeObject(object obj)
        {
            Type t = obj.GetType();
            XmlDocument doc = JsonConvert.DeserializeXmlNode(JsonConvert.SerializeObject(obj), t.Name);
            return "<?xml version=\"1.0\" ?>" + doc.OuterXml;
        }
    }
}
